package main.model;

import java.util.ArrayList;
import java.util.List;

public class Hierarchy extends Component implements Identifiable{

	private Entity parent;
	private String type;
	private List<Entity> entities;
	public static final String cobTotalExcl = "Total-Exclusiva";
	public static final String cobTotalSuper = "Total-Superpuesta";
	public static final String cobParcialExcl = "Parcial-Exclusiva";
	public static final String cobParcialSuper = "Parcial-Superpuesta";
	
	public Hierarchy(){
		this.setEntities(new ArrayList<Entity>());
	}
	
	public Entity getParent(){
		return this.parent;
	}
	
	public void setParent(Entity e){
		this.parent = e;
	}
	
	public void addEntity(Entity e){
		this.getEntities().add(e);
	}
	
	public Boolean removeEntity(Entity e){
		return this.getEntities().remove(e);
	}
	
	public void removeAllEntities(){
		this.setEntities(new ArrayList<Entity>());
	}
	
	public void setType(String type) {
		this.type = type;
	}

	public String getType() {
		return type;
	}
	
	public String getFormattedType(){
		if (Hierarchy.cobParcialExcl.equals(this.type)){
			return "(P-E)";
		} else if (Hierarchy.cobParcialSuper.equals(this.type)){
			return "(P-S)";
		} else if (Hierarchy.cobTotalExcl.equals(this.type)){
			return "(T-E)";
		} else {
			return "(T-S)";
		}
	}

	public void setEntities(List<Entity> entities) {
		this.entities = entities;
	}

	public List<Entity> getEntities() {
		return entities;
	}

	@Override
	public boolean isHierarchy() {
		return Boolean.TRUE;
	}

}
